package com.flx.at.spring.code.test.testbeanregister;

import com.flx.at.spring.code.test.testbeanregister.beanfactory.MyFactoryBean;
import com.flx.at.spring.code.test.testbeanregister.beanregister.BeanRegister;
import com.flx.at.spring.code.test.testbeanregister.component.BeanA;
import com.flx.at.spring.code.test.testbeanregister.component.BeanC;
import com.flx.at.spring.code.test.testbeanregister.importselect.BeanImportSelector;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * @Author: Fenglixiong
 * @Date: 2021/7/3 18:09
 * @Description:
 *
 * 注册bean组件的几种方式
 *
 * @Bean
 * @ComponentScan
 * @Import
 * ImportSelector
 * ImportBeanDefinitionRegistrar(动态注册bean)需要配合Import使用
 * FactoryBean接口实现组件注册，使用于创建初期需要设置大量内容场景
 *
 */
@Configuration
@Import({BeanC.class, BeanImportSelector.class, BeanRegister.class})
public class BeanRegisterConfig {

    @Bean
    public BeanA beanA(){
        return new BeanA();
    }

    @Bean
    public MyFactoryBean myFactoryBean(){
        return new MyFactoryBean();
    }

}
